package com.ruoyi.web.controller.strategyTest;

public class Context {
    private Strategy strategy;
    public Context(Strategy strategy){
        this.strategy=strategy;
    }
    public void execute()
    {
        strategy.execute();
    }
    // 使用方式
    public static void main(String[] args) {
        final ConcreteStrategyA concreteStrategyA = new ConcreteStrategyA();
        final Context context = new Context(concreteStrategyA);
        context.execute();
        final ConcreteStrategyB concreteStrategyB = new ConcreteStrategyB();
        final Context context1 = new Context(concreteStrategyB);
        context1.execute();
    }
}

